export default {
	data() {
		return {
			userLogStart: 0
		}
	},
	created: function() {
	},
	onReady: function(e) {
		
	},
	onLoad() {
		console.log('monitor onLoad')
		this.userLogStart = this.$moment().format('X')
	},
	onHide() {
		console.log('monitor onHide')
		this.userAccessLog()
	},
	onUnload() {
		console.log('monitor onUnload')
		this.userAccessLog()
	},
	methods: {
		async userAccessLog() {
			console.log('-------------------------userAccessLog-------------------------')
			var that = this
			const monitorValue = this.monitorValue
			const userLogStart = this.userLogStart
			const userLogEnd = this.$moment().format('X')
			if (!monitorValue || !userLogStart || !userLogEnd ) {
				console.log('monitor return')
				return
			}
			let data = {
				...monitorValue,
				scene: 'gzh',
				value: userLogEnd - userLogStart
			}
			if(data.content && data.content.id) {
				data['obj_id'] = data.content.id
			}
			let res = await this.$request.post('/api/report', {
				loading: false,
				data: data
			})
		},
		async userBehavior(monitorValue) {
			console.log('-------------------------userBehavior-------------------------')
			var that = this
			let data = {
				...monitorValue,
				scene: 'gzh',
				// value: userLogEnd - userLogStart
			}
			if(data.content && data.content.id) {
				data['obj_id'] = data.content.id
			}
			let res = await this.$request.post('/api/report', {
				loading: false,
				data: data
			})
		},
		
	}
}
